package ctn.event;

import java.io.Serializable;
import java.lang.reflect.Field;

import ctn.util.StringUtils;

public abstract class CTNEvent implements Serializable{
	private String desc;
	public String getEventID() {
		return null;
	}
	
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
	public abstract String toEventLink();
	public void setPropValue(String eventLink) {
		if(!StringUtils.isEmptyString(eventLink)){
			String[] propvalues=eventLink.split(";");
			for(String propvalue:propvalues){
				if(!StringUtils.isEmptyString(propvalue)){
					String[] pvs=propvalue.split(":");
					Class c=this.getClass();
					try {
						
						Field f=c.getDeclaredField(pvs[0]);
						f.setAccessible(true);
						f.set(this, pvs[1]);
					} catch (SecurityException e) {
						e.printStackTrace();
					} catch (NoSuchFieldException e) {
						e.printStackTrace();
					} catch (IllegalArgumentException e) {
						e.printStackTrace();
					} catch (IllegalAccessException e) {
						e.printStackTrace();
					}
				}
			}
		}
	}
}
